/*****
 * 目前Mock不支持fetch方法，调试了好半天，真是日了狗了
 */
import Mock from 'mockjs';

// const mock = Mock.mock('http://localhost:8888/',{
//   'name': '@name',
//   'age|1-100': 100,
//   'color': '@color'
// });
let Random = Mock.Random;
Random.cname();
Random.csentence(4);
const StoreLlists = Mock.mock('https://cloud.xyitech.com/store/search/', {
  'msg|10': [
    {
      'id|+1': 1,
      'name': '@csentence(4)',
      'lat|30.10': 1.4918,
      'lng|119.10': 1.5240,
      'update_time|+1': 1502678783,
      'aid|+1': 0,
      'version|1': ['production', 'debug'],
      'uid|+1': 0,
    }
  ],
  'err': 0
});
// https://cloud.xyitech.com/store/search?token=MSMxNDkxMDA5Njc2QGppZXlhbi54eWl0ZWNoLmNvbSNoT1JGeXdIbTNmZnhFc09nTHh6VTNlbElVb2s9&v=debug
const mock = {StoreLlists};
export default mock
// export default {
//   'GET /mock': (req, res) => {
//     res.setHeader('Access-Control-Allow-Origin', '*');
//     setTimeout(() => {
//       res.json({      //将请求json格式返回
//         success: true,
//         data,
//         page: '123',
//       });
//     }, 200);
//   }
// };
// fetch('/mock', {
//   method: 'GET',
//   mode: 'cors',// 避免cors攻击
//   credentials: 'include'
// })
//   .then((response) => response.json())
//   .then((responseText) => {
//     console.log('啦啦啦~mock数据是', responseText);
//   })
//   .catch((err) => {
//     console.log("Oops, error,",);
//     alert("网络错误，请稍后重试");
//     return true
//   });
// fetch(`https://cloud.xyitech.com/item/search?token=MTEwIzE1MDY2NTc2ODBAY2xvdWQueHlpdGVjaC5jb20jdmp5d1JWWHRDengrWW9MZnAxZisxUTlTUExrPQ==&page_size=10&page_no=0&v=debug`)
//   .then((res) => {
//     // console.log('fetchBasicItemsPosts  is ', res);
//     return res.json()
//   })
//   .then((data) => {
//     console.log('fetchBasicItemsPosts  is ', data);
//   })
//   .catch((e) => {
//     console.log(e)
//   })